GBML manual / Database

db_set

Changes one cell of a table while the game runs: db_set(cars, "falcon", top_speed, 3). It is exactly the same as writing cars.falcon.top_speed = 3. Only a column with Varying turned on can change; the cells of a fixed column are part of the game itself and writing one is a message that tells you to turn Varying on. A varying column starts at the table’s own value every time the game starts.

Syntax

db_set(table, row, column, value)

Arguments

NameType
tabletable
rowstring
columncolumn
valueany

Returns

Nothing.

Description

Changes one cell of a table while the game runs: db_set(cars, "falcon", top_speed, 3). It means exactly the same as cars.falcon.top_speed = 3.

Only a column with Varying turned on can change. The cells of a fixed column are part of the game itself, and writing one is a message that tells you to turn Varying on in the table. Giving the wrong kind of value (text into a number column) is a message too.

A varying column starts from the table's own values every time the game starts, so what you change is not saved into the table.

Example

db_set(cars, "falcon", fuel, 3);
cars.falcon.laps += 1;

On the GBA

A Varying column keeps one place in the game’s memory for every row, so it costs memory (a whole number or a decimal takes 4 bytes, text takes the text size set in Project Settings, yes or no takes 1). A fixed column costs none. Changing a cell does not change the table you edit: the next time the game starts it begins from the table again.

See also: db_getTablesReading a cell the short wayVarying columns